package com.hq.service;

import com.hq.bean.User;
import com.hq.dao.UserDao;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    private static final String SALT = "sadfddsdafa";
    @Resource
    UserDao userDao;

    @Override
    public User login(User user) {
        return userDao.login(user);
    }

    @Override
    public int register(User user) {
        String s = DigestUtils.md5Hex(user.getPwd() + SALT + user.getUname());
        user.setPwd(s);
        return userDao.register(user);
    }
}
